package com.example.test02.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.test02.R;

public class UploadRecordAdapter extends ArrayAdapter<String> {
    private final Context context;
    private final String[] recordDates;
    private final String[] recordTitles;
    private final String[] recordStatus;

    public UploadRecordAdapter(Context context, String[] recordDates, String[] recordTitles, String[] recordStatus) {
        super(context, R.layout.recorders, recordDates);
        this.context = context;
        this.recordDates = recordDates;
        this.recordTitles = recordTitles;
        this.recordStatus = recordStatus;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.recorders, parent, false);
        }

        TextView dateTextView = convertView.findViewById(R.id.record_date);
        TextView titleTextView = convertView.findViewById(R.id.record_title);
        TextView statusTextView = convertView.findViewById(R.id.record_status);

        dateTextView.setText(recordDates[position]);
        titleTextView.setText(recordTitles[position]);
        statusTextView.setText(recordStatus[position]);

        return convertView;
    }
}
